import os.path
import bipy.components
import pyglet.image
import pyglet.resource
import os
class ImageManager(bipy.components.Component):
    __default_path = 'img'
    
    def __init__(self, art_path = None):
        super(ImageManager, self).__init__('images', 100)
        
        self.__image_cache = {}
        if art_path and os.path.isdir( art_path ):
            self.__path = art_path
        else:
            self.__path = self.__default_path
        print self.__path
        
    def get(self, name):
        if name in self.__image_cache:
            return self.__image_cache[ name ]
        self.__image_cache[ name ] = pyglet.image.load( os.path.join(self.__path, name) )
        return self.__image_cache[ name ]
        
component_class = ImageManager
        